#!/bin/sh

make clean;
make;
#task1 1K

if [ ! -d "task1_1k" ]; then
	mkdir task1_1k	
else
	rm -rf task1_1k/*
fi

for rho in 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
do
	./queuesimulation $rho 20 1000 10 >> task1_1k/output_task1_1k 
done

grep 'Customer loss rate*' task1_1k/output_task1_1k | awk '{print $5}' >> task1_1k/clr.result

#task1 100K

if [ ! -d "task1_100k" ]; then
	mkdir task1_100k
else
	rm -rf task1_100k/*
fi

for rho in 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
do
	./queuesimulation $rho 20 100000 10 >> task1_100k/output_task1_100k 
done

grep 'Customer loss rate*' task1_100k/output_task1_100k | awk '{print $5}' >> task1_100k/clr.result


#task2 1K

if [ ! -d "task2_1k" ]; then
	mkdir task2_1k
else
	rm -rf task2_1k/*
fi

for k in 10 20 30 40 50 60 70 80 90 100
do
	./queuesimulation 0.85 $k 1000 10 >> task2_1k/output_task2_1k
done

grep 'Customer loss rate*' task2_1k/output_task2_1k | awk '{print $5}' >> task2_1k/clr.result


#task2 100K

if [ ! -d "task2_100k" ]; then
	mkdir task2_100k
else
	rm -rf task2_100k/*
fi

for k in 10 20 30 40 50 60 70 80 90 100
do
	./queuesimulation 0.85 $k 100000 10 >> task2_100k/output_task2_100k
done

grep 'Customer loss rate*' task2_100k/output_task2_100k | awk '{print $5}' >> task2_100k/clr.result


#task3

if [ ! -d "task3" ]; then
	mkdir task3
else
	rm -rf task3/*
fi

for rho in 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
do
	./queuesimulation $rho 20 100000 10 >> task3/output_task3
done

grep 'Customer loss rate*' task3/output_task3 | awk '{print $5}' >> task3/clr.result

#task4

if [ ! -d "task4" ]; then
	mkdir task4
else
	rm -rf task4/*
fi

for rho in 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
do
	./queuesimulation $rho 100 100000 10 >> task4/output_task4
done

grep 'Average waiting time*' task4/output_task4 | awk '{print $5}' >> task4/waiting.result


#task5

make clean;
make noprint; 

if [ ! -d "task5" ]; then
	mkdir task5
else
	rm -rf task5/*
fi

for rho in 0.05 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.85 0.95
do
	./queuesimulation $rho 40 100000 10 >> task5/output_task5
done

grep 'Simulation time*' task5/output_task5 | awk '{print $4}' >> task5/sim.result
